
puts '[info] begin to analyze evaluating result...'
begin
  iFile = File.open('evaluation_result_dup.txt','r')
  oFile = File.open('evaluation_analyze_dup.txt','w')
  listArr = Array.new
  rownames = 'row.names=c('
  rownameArr = Array.new
  list = ''
  iFile.each_line { |line|
    arr = line.split(' ')
    next if arr[0]!='[info]'|| arr[1]=='evaluatingSetRatio' || arr[1]=='begin'
    if arr[1] == 'trainingSetRatio'
      if list!='' && list!=nil # process last list
        list.chop!
        list << ')'
        listArr.push(list) 
      end
      list = "\"#{arr[3]}\"=c("
    else
      list << arr[arr.size-1] << ','
      rownameArr.push(arr[1])
    end
  }
  rownameArr.uniq!
  rownameArr.each { |rowname|
    rownames << '"' << rowname << '",'
  }
  rownames.chop!
  rownames << '),'
  output = '"data" <- structure ('
  output << 'list('
  listArr.each { |list|
    output << list << ','
  }
  output.chop!
  output << '),'
  output << rownames
  output << "class=\"data.frame\")"
  puts output
ensure
  iFile.close if iFile != nil
  oFile.close if oFile != nil
end



